Skip to content

Make fabrics optional#3170

Merged
igaw merged 12 commits intolinux-nvme:masterfrom
igaw:disable-fabrics
Mar 13, 2026
Merged

Make fabrics optional#3170
igaw merged 12 commits intolinux-nvme:masterfrom
igaw:disable-fabrics

Conversation

@igaw
Copy link
Copy Markdown
Collaborator

@igaw igaw commented Mar 12, 2026

The fabrics part is rather large and usually is not necessary for embedded use cases. Also it is very Linux specific and makes any porting attempts really hard. Thus make the fabrics part optional.

@igaw igaw force-pushed the disable-fabrics branch from ed83cf4 to a9fb3a1 Compare March 12, 2026 10:36
@igaw igaw force-pushed the disable-fabrics branch 3 times, most recently from 4fd3c54 to 6bbfb96 Compare March 13, 2026 12:44
igaw added 3 commits March 13, 2026 18:47
With some more aggressive CFLAGS/LDFLAGS optimized for size the compiler
gets confused and can't figure out if ms is initialized or not.

../nvme.c:8567:20: error: ‘ms’ may be used uninitialized [-Werror=maybe-uninitialized]
 8567 |                 if (ms && cfg.metadata_size < mbuffer_size)
      |                    ^
../nvme.c:8356:15: note: ‘ms’ was declared here
 8356 |         __u16 ms;
      |               ^~

Signed-off-by: Daniel Wagner <[email protected]>
With some more aggressive CFLAGS/LDFLAGS optimized for size the compiler
gets confused and can't figure out if 'n' is initialized or not.

../libnvme/src/nvme/tree.c: In function ‘__nvme_scan_namespace’:
../libnvme/src/nvme/tree.c:2598:22: error: ‘n’ may be used uninitialized [-Werror=maybe-uninitialized]
 2598 |         n->sysfs_dir = path;
      |         ~~~~~~~~~~~~~^~~~~~
../libnvme/src/nvme/tree.c:2583:25: note: ‘n’ was declared here
 2583 |         struct nvme_ns *n;
      |                         ^

Signed-off-by: Daniel Wagner <[email protected]>
The musl build fails due to a missing include:

In file included from ../unit/test-uint128.c:8:
../unit/../util/types.h:60:16: error: unknown type name ‘time_t’
   60 | int convert_ts(time_t time, char *ts_buf);
      |                ^~~~~~
../unit/../util/types.h:11:1: note: ‘time_t’ is defined in header ‘<time.h>’; this is probably fixable by adding ‘#include <time.h>’
   10 | #include <libnvme.h>
  +++ |+#include <time.h>
   11 |

Signed-off-by: Daniel Wagner <[email protected]>
@igaw igaw force-pushed the disable-fabrics branch 2 times, most recently from 3bb0429 to a3aedce Compare March 13, 2026 18:02
When the nvme_dump_config function arguments got updated, the no-json
version was forgotten.

Fixes: 74b30d2 ("json: update nvme_dump_config to a file descriptor")
Signed-off-by: Daniel Wagner <[email protected]>
@igaw igaw force-pushed the disable-fabrics branch from a3aedce to 3e043db Compare March 13, 2026 18:03
igaw added 5 commits March 13, 2026 19:11
The nbft_info is defined in nbft thus move the linked list also there.
This decouples the dependencies between nbft.h and fabrics.h

Signed-off-by: Daniel Wagner <[email protected]>
The fabrics configuration data struct is always present, even the
fabrics code is disabled. Thus the struct needs always to be initialized

Signed-off-by: Daniel Wagner <[email protected]>
The hostid and hostnqn are used through out the library and are not
fabric specific. Because tree.c depends on it move it to linux.c, so
it's possible to make the fabrics code optional.

Signed-off-by: Daniel Wagner <[email protected]>
The symbol versioning never really worked, thus it's adding unnecessary
complexity. Thus the guarantee is that no existing symbols gets changed.

Signed-off-by: Daniel Wagner <[email protected]>
The fabrics part is rather large and usually is not necessary for
embedded use cases. Also it is very Linux specific and makes any porting
attempts really hard. Thus make the fabrics part optional.

Signed-off-by: Daniel Wagner <[email protected]>
@igaw igaw force-pushed the disable-fabrics branch from 3e043db to c3f86b9 Compare March 13, 2026 18:13
@igaw igaw marked this pull request as ready for review March 13, 2026 18:17
@igaw igaw requested a review from Copilot March 13, 2026 18:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the NVMe-oF (fabrics) functionality optional, motivated by embedded use cases where fabrics support is unnecessary and its Linux-specific dependencies hinder porting. It separates the fabrics code path behind a new fabrics meson option (enabled by default), splits the linker script, moves host identity functions from fabrics.c to linux.c, and conditionally compiles fabrics-related commands, tests, and examples.

Changes:

  • Introduces a fabrics meson feature option and gates fabrics source files, tests, examples, headers, and dependencies (liburing, openssl, keyutils, libdbus, python) on it.
  • Moves host identity functions (hostnqn_generate, hostid_from_file, etc.) from fabrics.c to linux.c with renamed nvme_* prefixes (from nvmf_*), and splits the linker script into libnvme.ld and libnvmf.ld.
  • Adds a minimal_static build configuration with aggressive size optimizations and fabrics disabled, along with corresponding CI workflow.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
meson_options.txt Adds new fabrics feature option
meson.build Gates dependencies and sources on want_fabrics
libnvme/src/meson.build Splits sources/headers lists, adds libnvmf.ld, generates libnvme.h from template
libnvme/src/libnvme.h.in Conditionally includes fabrics/nbft headers via @FABRICS_INCLUDE@
libnvme/src/libnvme.ld Removes fabrics symbols, bumps version to LIBNVME_3, adds new nvme_host* symbols
libnvme/src/libnvmf.ld New linker script for fabrics symbols under LIBNVMF_3
libnvme/src/nvme/linux.h Declares new nvme_hostnqn_* / nvme_hostid_* functions
libnvme/src/nvme/linux.c Moves host identity and UUID functions from fabrics.c
libnvme/src/nvme/fabrics.h Removes moved function declarations, forward-declares nbft_file_entry
libnvme/src/nvme/fabrics.c Removes moved functions and constants
libnvme/src/nvme/tree.c Receives nvmf_default_config, renames calls to new API
libnvme/src/nvme/nbft.h Moves nbft_file_entry struct definition here
libnvme/src/nvme/no-json.c Updates json_update_config signature
nvme.c Guards fabrics commands with #ifdef CONFIG_FABRICS, renames API calls, simplifies submit_io error handling
nvme-builtin.h Guards fabrics ENTRY macros, moves dim entry inside guard
nvme-print-stdout.c Guards fabrics-specific print functions, provides empty stubs when disabled
nvme-print-json.c Guards fabrics-specific JSON print functions, provides empty stubs when disabled
util/cleanup.h Guards _cleanup_uri_ behind CONFIG_FABRICS
util/types.h Adds #include <time.h>
plugins/meson.build Makes nbft plugin conditional on fabrics
scripts/build.sh Adds minimal_static build config
scripts/release.sh Removes ldscripts processing (now split)
.github/workflows/build.yml Adds CI job for minimal_static build
libnvme/test/meson.build Gates uriparser and nbft tests on fabrics
libnvme/test/ioctl/meson.build Gates discovery test on fabrics
libnvme/examples/meson.build Gates discover-loop example on fabrics
libnvme/libnvme/nvme.i Updates SWIG bindings to use new function names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread libnvme/src/nvme/linux.h Outdated
Comment thread libnvme/src/nvme/linux.h
Comment thread .github/workflows/build.yml Outdated
@igaw igaw force-pushed the disable-fabrics branch 2 times, most recently from 6709093 to c4c95bc Compare March 13, 2026 18:28
igaw added 3 commits March 13, 2026 19:30
Add a CI test for building without fabrics code. While at it also use
some non standard CFLAGS and LDFLAGS.

Signed-off-by: Daniel Wagner <[email protected]>
Use a local array for the CFLAGS to improve readability.

Signed-off-by: Daniel Wagner <[email protected]>
Fix a couple of typos.

Signed-off-by: Daniel Wagner <[email protected]>
@igaw igaw force-pushed the disable-fabrics branch from c4c95bc to aff7afd Compare March 13, 2026 18:30
@igaw igaw merged commit 270e812 into linux-nvme:master Mar 13, 2026
28 checks passed
@igaw igaw deleted the disable-fabrics branch March 13, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants